# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models

# Create your models here.


class Test(models.Model):
	name = models.CharField(max_length=100)
	age = models.IntegerField()
	hobby = models.CharField(max_length=100)

class Publisher(models.Model):
	name = models.CharField('名称',max_length=30)
	address = models.CharField('地址',max_length=50)
	city = models.CharField('城市',max_length=60)
	state_province = models.CharField('省份',max_length=30)
	country = models.CharField('国家',max_length=50)
	website = models.URLField('网址')

	class Meta:
		verbose_name = '出版商'
		verbose_name_plural = verbose_name

	def __unicode__(self):
		return self.name

class Author(models.Model):
	name = models.CharField(verbose_name='姓名',max_length=30)

	class Meta:
		verbose_name = '作者'
		verbose_name_plural = verbose_name

class AuthorDetail(models.Model):
	sex = models.BooleanField(max_length=1,choices=((0,'男'),(1,'女'),))
	email = models.EmailField()
	address = models.CharField(max_length=50)
	birthday = models.DateField()
	author = models.OneToOneField(Author)

	class Meta:
		verbose_name_plural = '作者详情'

class Book(models.Model):
	title = models.CharField(max_length=100)
	authors = models.ManyToManyField(Author)
	publisher = models.ForeignKey(Publisher)
	publication_date = models.DateField()
	price = models.DecimalField(max_digits=5,decimal_places=2,default=None)

	class Meta:
		verbose_name_plural = '书'

